package itcast.web.servlet;

import itcast.domain.Drom;
import itcast.domain.Studnet;
import itcast.service.Drom_manageService;
import itcast.service.StudentService;
import itcast.service.impl.Drom_manageServiceImpl;
import itcast.service.impl.StudentServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet("/updatedrom_exchangeServlet")
public class Updatedrom_exchangeServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //设置编码
        request.setCharacterEncoding("utf-8");
        //2.获取map
        Map<String,String[]> map=request.getParameterMap();
        //3.封装对象
        Studnet studnet=new Studnet();
        try {
            BeanUtils.populate(studnet,map);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        //调用Service
        StudentService service=new StudentServiceImpl();
        service.updatedrom_exchange(studnet);
        //跳转到查询所有的Servlet
        response.sendRedirect(request.getContextPath()+"/drom_exchangefindServlet");

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request,response);
    }
}
